/**
 * 
 * If you have edited the file, please update
 * all the last-modified fields manually. Thanks!
 *
 * @last-modified by: 
 * @last-modified date: 
 * @last-modified time: 
 *
 * @author Swee Zhi
 * @date-created Sep 26, 2011    @time-created 11:50:43 PM
 *
 * @project: 
 * @module: 
 * @institution: 
 *
 */
package util.generator;

import entity.AccessRightsEntity;
import java.util.List;
import javax.faces.context.FacesContext;
import org.primefaces.component.menuitem.MenuItem;
import org.primefaces.model.MenuModel;
import util.entityhelper.StaffAccountState;

public class StaffMenuGenerator {
    private StaffAccountState staffAccountState;
    private MenuModel model;
            
    public StaffMenuGenerator (StaffAccountState staffAccountState) {
        this.staffAccountState = staffAccountState;
    }
    
    public MenuModel generateStaffMenu() {
        List<AccessRightsEntity> staffAccessList = staffAccountState.getAccessRights();
        
        MenuItem menu1 = new MenuItem();
        menu1.setValue("Manage Account Details");
        menu1.setUrl(FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()+"/staff/ViewStaffAccount.xhtml");
        model.addMenuItem(menu1);
        
        MenuItem menu2 = new MenuItem();
        menu2.setValue("Verify Stakeholder Account");
        menu2.setUrl("#");
        model.addMenuItem(menu2);
        
        for (int i = 0; i < staffAccessList.size(); i++) {
            if (staffAccessList.get(i).getAccessRight().toString().equalsIgnoreCase("ADD_TCUBE_USER")) {
                MenuItem menu3 = new MenuItem();
                menu3.setValue("Add New TCube User");
                menu3.setUrl(FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()+"/StaffRegister.xhtml");
                model.addMenuItem(menu3);
            }else if(staffAccessList.get(i).getAccessRight().toString().equalsIgnoreCase("UNLOCK_ACCOUNTS"))
            {
                MenuItem menu3 = new MenuItem();
                menu3.setValue("Unlock Accounts");
                menu3.setUrl(FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()+"/staff/UnlockingOfAccounts.xhtml");
                model.addMenuItem(menu3);
            }
            else if(staffAccessList.get(i).getAccessRight().toString().equalsIgnoreCase("EDIT_ACCESS_RIGHTS"))
            {
                MenuItem menu3 = new MenuItem();
                menu3.setValue("Edit staff access rights");
                menu3.setUrl(FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()+"/staff/EditStaffAccessRights.xhtml");
                model.addMenuItem(menu3);
            }
        }
        
        return model;
    }
}
